//
//  SNOrderFormListCell.m
//  app
//
//  Created by 王少宁 on 15/5/5.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//  订单列表 cell

#import "SNOrderFormListCell.h"

@interface SNOrderFormListCell ()
@property (nonatomic, retain) UIImageView * goodsImageView;
@property (nonatomic, retain) UILabel * titleLabel;
@property (nonatomic, retain) UILabel * moneyLabel;
@property (nonatomic, retain) UILabel * countLabel;
@end

@implementation SNOrderFormListCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self crateCell];
    }
    return self;
}

- (void)crateCell
{
    _goodsImageView = CREATE_WITH_FRAME_OF(UIImageView, CGPointMake(10, 11),
                                           [self.contentView.ubo ow:64 oh:64]);
    _goodsImageView.layer.borderWidth = UP(1);
    _goodsImageView.layer.borderColor = [XCommon hexStringToColor:kColor_gray_line].CGColor;
    [self.contentView addSubview:_goodsImageView];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = JKAppGlobleFontSmallTagText;
    _titleLabel.textColor = [XCommon hexStringToColor:kColor_l_light_gray_text];
    _titleLabel.numberOfLines = 0;
    [self.contentView addSubview:_titleLabel];
    
    _moneyLabel = CREATE_WITH_FRAME_OF(UILabel, [_goodsImageView.ufo fx:1.0 ox:10 fy:1.0 oy:-30],
                                       [self.contentView.ubo ow:100 oh:30]);
    _moneyLabel.font = [UIFont boldSystemFontOfSize:13];
//    _moneyLabel.textColor = [XCommon hexStringToColor:kColor_main_theme_orange];
    [self.contentView addSubview:_moneyLabel];
    
    _countLabel = CREATE_WITH_FRAME_OF(UILabel, [self.contentView.ufo ox:SCREEN_WIDTH-50-UF(24) oy:_moneyLabel.ufo.y],
                                       [self.contentView.ubo ow:50 oh:30]);
    _countLabel.font = JKAppGlobleFontSmallTagText;
    _countLabel.textColor = [XCommon hexStringToColor:kColor_s_light_gray_text];
    _countLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_countLabel];
}

- (void)cellWithModel:(SNOrderFormListModel *)model
{    
    [_goodsImageView sd_setImageWithURL:[NSURL URLWithString:model.title_pic]];
    CGFloat height = [XCommon heightForString:model.product_title fontSize:13 andWidth:SCREEN_WIDTH-UF(24)-10-_goodsImageView.ufo.xx];
    _titleLabel.frame = CGRectOf([_goodsImageView.ufo fx:1.0 ox:10 fy:0],
                                 [self.contentView.ubo ow:SCREEN_WIDTH - _goodsImageView.ubo.width - 30 oh:height]);
    _titleLabel.text = model.product_title;
    _moneyLabel.text = [NSString stringWithFormat:@"￥%@",model.price];
    _countLabel.text = [NSString stringWithFormat:@"×%@",model.product_num];
}

- (void)drawRect:(CGRect)rect
{
    [self drawHorizonLineLeft:10 right:0 at:UP(1)];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
